<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div id="app">
    <!-- <div>{{msg}}</div> -->
    <my-test />
  </div>
  <script src="https://cdn.jsdelivr.net/npm/vue@2.6.14/dist/vue.js"></script>
  <script>
    // 自定义全局组件
    Vue.component('my-com', {
      template: '<div>{{info}}</div>',
      data () {
        return {
          info: 'nihao'
        }
      }
    })

    Vue.component('my-test', {
      render (createElement) {
        // createElement的作用：创建元素
        // <div class='active'>hello</div>
        // const vnode = createElement('div', { class: 'active' }, 'hello')
        // return vnode
        // ---------------------------------------------------------
        // <ul><li>apple</li><li>orange</li><li>peach</li></ul>
        const l1 = createElement('li', null, 'apple')
        const l2 = createElement('li', null, 'orange')
        const l3 = createElement('li', null, 'peach')

        const ul = createElement('ul', null, [l1, l2, l3])
        return ul
      }
    })

    // 所有的组件都是Vue的构造函数的实例对象
    // new Vue也是组件：el给根组件提供了模板(el仅仅可以用在根组件上)
    new Vue({
      el: '#app',
      data: {
        msg: 'hello'
      }
    })
  </script>
</body>
</html>